/*
 * binaryheap.h
 *
 *  Created on: Jun 17, 2010
 *      Author: Guilherme
 */

#ifndef BINARYHEAP_H_
#define BINARYHEAP_H_

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

typedef int distance;
struct heapstruct;
struct heapnode;
typedef struct heapnode *HeapNode;
typedef struct heapstruct *PriorityQueue;

struct heapnode {
	int nodeID;
	distance distance;
};

struct heapstruct {
    int capacity;
    int size;
    int *positions;
    struct heapnode **nodes;
};

PriorityQueue init(int maxElements);
void insert(HeapNode node, PriorityQueue Q);
HeapNode deleteMin(PriorityQueue Q);
HeapNode findMin(PriorityQueue Q);
void decreaseKey(HeapNode node, PriorityQueue Q);
void destroy(PriorityQueue Q);
void makeEmpty(PriorityQueue Q);
int isEmpty(PriorityQueue Q);
int isFull(PriorityQueue Q);
void print_heap(PriorityQueue Q);
void percolateDown(int hole, PriorityQueue Q);



#endif /* BINARYHEAP_H_ */
